package com.hk.elseservice.mapper;


import com.hk.model.CompanyMessage;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Update;

import java.util.List;


/**
 * @Author: zhe
 * @Date: 2021/6/11 15:07
 * @Statement: 公司信息Mapper接口
 */
public interface CompanyMessageMapper extends BaseMapper<CompanyMessage> {

    /**
     * 1、在修改状态前，将所有状态修改为未启用 updateState1()
     * 2、将当前Id对应公司信息状态修改为启用 updateState(CompanyMessage companyMessage);
     * @param companyMessage
     * @return
     */
    @Update("update company_message set state=#{state},gmt_modified=#{gmtModified} where id = #{id} ")
    int updateState(CompanyMessage companyMessage);
    @Update("update company_message set state = 1")
    int updateState1();

    @Override
    List<CompanyMessage> findAll(CompanyMessage companyMessage);

    @Override
    int count(CompanyMessage companyMessage);

    @Override
    CompanyMessage findById(Integer id);

    CompanyMessage findByState(CompanyMessage companyMessage);

    @Insert("insert into company_message " +
            "  value (" +
            " null ,#{name},#{nameEnglish},#{phone},#{startTime},#{endTime},#{idea}," +
            " #{ideaEnglish},#{profile},#{title},#{detail},#{state},#{gmtCreate},#{gmtModified}" +
            " )")
    @Override
    int save(CompanyMessage companyMessage);

    @Update("update company_message " +
            "set " +
            "name=#{name},name_english=#{nameEnglish},phone=#{phone},start_time=#{startTime},end_time=#{endTime}," +
            "idea=#{idea},idea_english=#{ideaEnglish},profile=#{profile},title=#{title},detail=#{detail},gmt_modified=#{gmtModified}" +
            " where id = #{id} ")
    @Override
    int update(CompanyMessage companyMessage);

    @Delete("delete from company_message where id = #{id} ")
    @Override
    int delete(Integer id);

}
